Dynomotion

Group: DynoMotion Message: 10770 From: Colin Fera Date: 1/4/2015
Subject: center find user button
Can anyone advise me as to the best way to add a user button which divides the current DRO reading for a particular axis by 2 and sets it to this value.  

Basically what I am after is something that mimics the center find function common to milling machine DRO's for manual mills.



Thanks,
-Colin
Group: DynoMotion Message: 10773 From: Tom Kerekes Date: 1/5/2015
Subject: Re: center find user button
Hi Colin,

Are you using KMotionCNC?  If so, try this:



#include "KMotionDef.h"

#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"

main()
{
    double DROx, DROy, DROz, DROa, DROb, DROc;
    GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
    DoPCFloat(PC_COMM_SET_X, DROx/2);
}



Regards
TK




Group: DynoMotion Message: 10775 From: Colin Fera Date: 1/5/2015
Subject: Re: center find user button
Hi Tom,

This looks perfect thanks.

-Colin 
Group: DynoMotion Message: 10801 From: Colin Fera Date: 1/10/2015
Subject: Re: center find user button
Hi Tom,

I added this to a while(1) loop in my init program as seen below where bit50 is an IO bit assigned to the center x button.  I was expecting the x DRO to not change but it ends up adding -4.9787 to whatever is displayed.  IE if x is 0, it will be -4.97 hitting it again adds -4.97 to that value and so forth.  The issue isn't in the " DoPCFloat(PC_COMM_SET_X, DROx);"   its somewhere in the code that gets the DRO values.

Any ideas?

#include "KflopToKMotionCNCFunctions.c"

double DROx, DROy, DROz, DROa, DROb, DROc;

while(1){
if(ReadBit(50)){
   GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
DoPCFloat(PC_COMM_SET_X, DROx);
ClearBit(50);
}
}



On Mon, Jan 5, 2015 at 10:56 AM, Colin Fera <colin.fera@...> wrote:
Hi Tom,

This looks perfect thanks.

-Colin 

Group: DynoMotion Message: 10803 From: Tom Kerekes Date: 1/12/2015
Subject: Re: center find user button
Hi Colin,

Seems to work ok for me.   There is a define to specify which KFLOP persist variables are used to pass information.  Such as:

#define TMP 10 // which spare persist to use to transfer data

Did you include that?  Otherwise I would expect you would get an error.  Post your entire program.  What KMotion Version are you running?

Regards
TK

Group: DynoMotion Message: 10804 From: Colin Fera Date: 1/12/2015
Subject: Re: center find user button

Hi Tom,

I did not include the persist define.  Since I would be getting X and Y (not at the same time) would I need more than one? 

Will send the program when I get home.

Thanks,
-Colin

On Jan 12, 2015, at 11:01, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:

 

Hi Colin,

Seems to work ok for me.   There is a define to specify which KFLOP persist variables are used to pass information.  Such as:

#define TMP 10 // which spare persist to use to transfer data

Did you include that?  Otherwise I would expect you would get an error.  Post your entire program.  What KMotion Version are you running?

Regards
TK

Group: DynoMotion Message: 10808 From: Tom Kerekes Date: 1/12/2015
Subject: Re: center find user button
Hi Colin,

I can't see how the file would compile without an error if TMP was not defined.  Did you check if it compiled correctly in the KMotion.exec C Programs Screen?

Only one TMP definition is required.  The same TMP persist region is temporarily used for all the various transfers between KFLOP and KMotionCNC.

HTH
Regards
TK


From: "Colin Fera colin.fera@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Sent: Monday, January 12, 2015 12:04 PM
Subject: Re: [DynoMotion] center find user button

 

Hi Tom,

I did not include the persist define.  Since I would be getting X and Y (not at the same time) would I need more than one? 

Will send the program when I get home.

Thanks,
-Colin



On Jan 12, 2015, at 11:01, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:

 
Hi Colin,

Seems to work ok for me.   There is a define to specify which KFLOP persist variables are used to pass information.  Such as:

#define TMP 10 // which spare persist to use to transfer data

Did you include that?  Otherwise I would expect you would get an error.  Post your entire program.  What KMotion Version are you running?

Regards
TK

Group: DynoMotion Message: 10875 From: Colin Fera Date: 1/18/2015
Subject: Re: center find user button
Hi Tom,

You were right I had the TMP defined:

Here is the complete program, still sets the DRO to some oddball value.  I am sure some of the stuff in here is redundant and unnecessary. 

Thanks,
Colin

#include "KMotionDef.h"
#define TMP 10 
 #include "KflopToKMotionCNCFunctions.c"




#define MSPI 80000000
#define ZMIN -5
#define ZMAX 0
#define XMIN 0
#define XMAX 17.5
#define YMIN 0
#define YMAX 11
#define CNTS_PER_INCH_X 2000
#define CNTS_PER_INCH_Y 2000
#define CNTS_PER_INCH_Z 2000
#define X_TC 0
#define Y_TC 0
#define Z_TC 0
#define X 2
#define Y 0
#define Z 1
#define MaxY 21000
#define MinY -100
#define MaxZ 100
#define MinZ -9700
#define MaxX 34500
#define MinX -100


double DROx, DROy, DROz, DROa, DROb, DROc;

main()
{
 
EnableAxisDest(Y,ch0->Dest);  //y
    EnableAxisDest(Z,ch1->Dest);   //z
EnableAxisDest(X,ch2->Dest);   //x   
 // EnableAxisDest(Y,12919);  //y
// EnableAxisDest(1,0);   //z
// EnableAxisDest(2,22640);   //x  
ch0->SoftLimitPos=MaxY;       //y
ch0->SoftLimitNeg=MinY;         //y
ch1->SoftLimitPos=MaxZ;         //z
ch1->SoftLimitNeg=MinZ;       //z
ch2->SoftLimitPos=MaxX;       //x
ch2->SoftLimitNeg=MinX;        //x
 
FPGA(STEP_PULSE_LENGTH_ADD) = 63;  
DefineCoordSystem(2,0,1,-1);
ch0->InputMode=NO_INPUT_MODE;
ch0->OutputMode=STEP_DIR_MODE;
ch0->Vel=3000;
ch0->Accel=8000;
ch0->Jerk=8000000;
ch0->P=1;
ch0->I=0;
ch0->D=0;
ch0->FFAccel=0;
ch0->FFVel=0;
ch0->MaxI=200;
ch0->MaxErr=1e+006;
ch0->MaxOutput=200;
ch0->DeadBandGain=1;
ch0->DeadBandRange=0;
ch0->InputChan0=0;
ch0->InputChan1=0;
ch0->OutputChan0=0;
ch0->LimitSwitchNegBit=48;
ch0->LimitSwitchPosBit=49;

ch0->MasterAxis=-1;
ch0->InputGain0=1;
ch0->InputGain1=1;
ch0->InputOffset0=0;
ch0->InputOffset1=0;
ch0->OutputGain=-1;
ch0->OutputOffset=0;
ch0->SlaveGain=1;
ch0->BacklashMode=BACKLASH_OFF;
ch0->BacklashAmount=0;
ch0->BacklashRate=0;
ch0->invDistPerCycle=1;
ch0->Lead=0;
ch0->MaxFollowingError=1000000000;
ch0->StepperAmplitude=20;

ch0->iir[0].B0=1;
ch0->iir[0].B1=0;
ch0->iir[0].B2=0;
ch0->iir[0].A1=0;
ch0->iir[0].A2=0;

ch0->iir[1].B0=1;
ch0->iir[1].B1=0;
ch0->iir[1].B2=0;
ch0->iir[1].A1=0;
ch0->iir[1].A2=0;

ch1->InputMode=NO_INPUT_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=2000;
ch1->Accel=4000;
ch1->Jerk=4000000;
ch1->P=1;
ch1->I=0;
ch1->D=0;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=200;
ch1->MaxErr=1e+006;
ch1->MaxOutput=200;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=0;
ch1->InputChan1=0;
ch1->OutputChan0=1;
ch1->LimitSwitchNegBit=50;
ch1->LimitSwitchPosBit=51;

ch1->MasterAxis=-1;
ch1->InputGain0=1;
ch1->InputGain1=1;
ch1->InputOffset0=0;
ch1->InputOffset1=0;
ch1->OutputGain=1;
ch1->OutputOffset=0;
ch1->SlaveGain=1;
ch1->BacklashMode=BACKLASH_OFF;
ch1->BacklashAmount=0;
ch1->BacklashRate=0;
ch1->invDistPerCycle=1;
ch1->Lead=0;
ch1->MaxFollowingError=1000000000;
ch1->StepperAmplitude=20;

ch1->iir[0].B0=1;
ch1->iir[0].B1=0;
ch1->iir[0].B2=0;
ch1->iir[0].A1=0;
ch1->iir[0].A2=0;

ch1->iir[1].B0=1;
ch1->iir[1].B1=0;
ch1->iir[1].B2=0;
ch1->iir[1].A1=0;
ch1->iir[1].A2=0;

ch2->InputMode=NO_INPUT_MODE;
ch2->OutputMode=STEP_DIR_MODE;
ch2->Vel=3000;
ch2->Accel=8000;
ch2->Jerk=8000000;
ch2->P=1;
ch2->I=0;
ch2->D=0;
ch2->FFAccel=0;
ch2->FFVel=0;
ch2->MaxI=200;
ch2->MaxErr=1e+006;
ch2->MaxOutput=200;
ch2->DeadBandGain=1;
ch2->DeadBandRange=0;
ch2->InputChan0=0;
ch2->InputChan1=0;
ch2->OutputChan0=2;

ch2->MasterAxis=-1;


ch2->InputGain0=1;
ch2->InputGain1=1;
ch2->InputOffset0=0;
ch2->InputOffset1=0;
ch2->OutputGain=1;
ch2->OutputOffset=0;
ch2->SlaveGain=1;
ch2->BacklashMode=BACKLASH_OFF;
ch2->BacklashAmount=0;
ch2->BacklashRate=0;
ch2->invDistPerCycle=1;
ch2->Lead=0;
ch2->MaxFollowingError=1000000000;
ch2->StepperAmplitude=20;

ch2->iir[0].B0=1;
ch2->iir[0].B1=0;
ch2->iir[0].B2=0;
ch2->iir[0].A1=0;
ch2->iir[0].A2=0;

ch2->iir[1].B0=1;
ch2->iir[1].B1=0;
ch2->iir[1].B2=0;
ch2->iir[1].A1=0;
ch2->iir[1].A2=0;
ClearBit(48); // used for soft limits turn off must re init to turn on
    ClearBit(49); // used for home
    ClearBit(50); // used for home
persist.UserData[10] = 0; //set current tool to zero force tool change on first M6
int lastz = ch1->Dest;
int lastx = ch2->Dest;
int lasty = ch0->Dest;
while(1){
if(ReadBit(48)) { //soft limits disable and manual home sequence
ch0->SoftLimitPos= 80000;       //y
ch0->SoftLimitNeg=-80000;         //y
ch1->SoftLimitPos=80000;         //z
ch1->SoftLimitNeg=-80000;       //z
ch2->SoftLimitPos=80000;       
ch2->SoftLimitNeg=-80000;   
ClearBit(48);
while(~ReadBit(48)){
if(ReadBit(49)){  //home sequence
EnableAxisDest(0,0); 
EnableAxisDest(1,0);
EnableAxisDest(2,0);
ClearBit(49);
}
WaitNextTimeSlice();
}

ClearBit(48);
ch0->SoftLimitPos=MaxY;       //y
ch0->SoftLimitNeg=MinY;         //y
ch1->SoftLimitPos=MaxZ;         //z
ch1->SoftLimitNeg=MinZ;       //z
ch2->SoftLimitPos=MaxX;       //x
ch2->SoftLimitNeg=MinX;        //x
}

if(ReadBit(49)){  //home sequence
EnableAxisDest(0,0); 
EnableAxisDest(1,0);
EnableAxisDest(2,0);
ClearBit(49);
ClearBit(48);
}
if(ReadBit(50)){  //center x
   GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
DoPCFloat(PC_COMM_SET_X, DROx);
ClearBit(50);
}
if(ReadBit(51)){  //center y
   GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
DoPCFloat(PC_COMM_SET_Y, DROy);
ClearBit(51);
}
WaitNextTimeSlice();
}


}

On Mon, Jan 12, 2015 at 2:55 PM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Hi Colin,

I can't see how the file would compile without an error if TMP was not defined.  Did you check if it compiled correctly in the KMotion.exec C Programs Screen?

Only one TMP definition is required.  The same TMP persist region is temporarily used for all the various transfers between KFLOP and KMotionCNC.

HTH
Regards
TK

Group: DynoMotion Message: 10883 From: Tom Kerekes Date: 1/20/2015
Subject: Re: center find user button
Hi Colin,

You are correct we have a bug.  I believe it relates to getting the DROs when the Axis are defined in an odd order instead of XYZ = 0,1,2 like yours are.

It will take some time to sort out.  As a workaround you might re-map your axis in standard order.

Regards
TK



Group: DynoMotion Message: 10888 From: Colin Fera Date: 1/21/2015
Subject: Re: center find user button

Hi Tom,  

The workaround worked great.  

Thanks,
Colin

Sent from my iPhone

On Jan 20, 2015, at 8:29, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:

 

Hi Colin,

You are correct we have a bug.  I believe it relates to getting the DROs when the Axis are defined in an odd order instead of XYZ = 0,1,2 like yours are.

It will take some time to sort out.  As a workaround you might re-map your axis in standard order.

Regards
TK